package com.sky.web.admin;


import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("/admin/workspace")
public class WorkSpaceController {

    @Autowired
    private ReportService reportService;


    //今日数据
    @GetMapping("/businessData")
    public Result businessData() {
        //获取当日时间
        LocalDate today = LocalDate.now();//为了service复用报表导出
        BusinessDataVO vo = reportService.businessData(today);
        return Result.success(vo);
    }

    //今日订单
    @GetMapping("/overviewOrders")
    public Result overviewOrders() {
        OrderOverViewVO vo = reportService.overviewOrders();
        return Result.success(vo);
    }

    //查询套餐总览
    @GetMapping("/overviewSetmeals")
    public Result turnoverStatistics() {
        CoutSetmealAndDishByStatus cs = reportService.countDishAndSetmealByStatus();
        SetmealOverViewVO vo = SetmealOverViewVO.builder()
                .sold(cs.getSoldSetmeal())
                .discontinued(cs.getDiscontinuedSetmeal())
                .build();
        return Result.success(vo);
    }
    //查询菜品总览
    @GetMapping("/overviewDishes")
    public Result userStatistics() {
        CoutSetmealAndDishByStatus cs = reportService.countDishAndSetmealByStatus();
        DishOverViewVO vo = DishOverViewVO.builder()
                .sold(cs.getSoldDish())
                .discontinued(cs.getDiscontinuedDish())
                .build();
        return Result.success(vo);
    }
  /*  //查询套餐总览
    @GetMapping("/overviewSetmeals")
    public Result turnoverStatistics() {
        SetmealOverViewVO vo = reportService.countSetmealByStatus()
        return Result.success(vo);
    }
  //查询菜品总览
    @GetMapping("/overviewDishes")
    public Result userStatistics() {
        DishOverViewVO vo =  reportService.countDishByStatus();
        return Result.success(vo);
    }*/

}
